package io.github.enbool.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import io.github.enbool.bean.form.UserForm;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@JsonIgnoreProperties(value = {"createTime", "updateTime", "deleted", "password"})
public class User extends AbstractUser {

	private static final long serialVersionUID = 1L;
	
	@Column(unique = true, nullable=false)
	private String username;
	
	private String email;

	@Column(unique = true)
	private String phone;

	@ManyToOne
    @JoinColumn(name="organization_id")
    private Organization organization;
	
	public User() {}
	public User(UserForm userForm){
		this.username = userForm.getUsername();
		this.phone = userForm.getPhone();
		this.email = userForm.getEmail();
		this.setGender(userForm.getGender());
		this.setNickName(userForm.getNickName());
	}
}
